<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../vue.js"></script>
</head>

<body>
    <div class="app">
        <p>{{obj[0].name3}}</p>
        <parent></parent>
    </div>

    <template id="parent">
        <div>
            <h1>{{name1}}</h1>

            <son :city="city" :pro="pro"></son>
        </div>
        
    </template>

    <template id="son">
        <div>
            <h3>{{name2}}-子元素来自{{pro}}-{{city}}</h3>
        <son_son :name2="name2" :city="city" :pro="pro"></son_son>
        </div>
    </template>

    <template id="son_son">
        <div>
            <h6>{{name4}}-后代元素来自{{name2}}-{{city}}-{{pro}}</h6>
        </div>
    </template>

</body>
<script>
    Vue.component("parent", {
        template: "#parent",
        data() {
            return {
                name1: "不吃鱼的猫",
                city: "武汉市",
                pro: "湖北省"
            }
        },

    })
    Vue.component("son", {
        template: "#son",
        data() {
            return {
                name2: "猫吃鱼"
            }
        },
        props: {
            pro: String,
            city: String
        }
    })
    Vue.component("son_son", {
        template: "#son_son",
        data() {
            return {
                name4: "猫吃鱼的儿子"
            }
        },
        props: {
            name2: String,
            pro: String,
            city: String
        }
    })


    const vm = new Vue({
        data: {
            obj: [{
                name3: "不吃鱼d猫"
            }, ]
        }

    }).$mount(".app")
</script>

</html>